<div>
  <!-- 添加分类按钮 -->
  <el-button type="success" plain @click="showAddCatDialoge"
    >添加分类</el-button
  >
  <!-- 表格 -->
  <el-table :data="catList" style="width: 100%">
    <!--
      展开行数列：可以直接加属性，介绍里面是驼峰，添加的时候要写成tree-key
      tree-key:默认是个id,能够找准自己的子节点
      parent-key:能够让子节点找到父节点
      level-key:根据层级进行缩进
      indent-size:再次进行缩进
     -->
    <el-table-tree-column
      file-icon="icon icon-file"
      folder-icon="icon icon-folder"
      prop="cat_name"
      label="分类名称"
      width="220"
      tree-key="cat_id"
      parent-key="cat_pid"
      level-key="cat_level"
      :indent-size="30"
    ></el-table-tree-column>
    <el-table-column label="是否有效" width="180">
      <template slot-scope="scope">
        <span>{{ scope.row.cat_deleted ? '否' : '是' }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="cat_level" label="层级"></el-table-column>
    <el-table-column label="操作"></el-table-column>
  </el-table>

  <!-- 添加分类对话框 -->
  <el-dialog title="添加分类" :visible.sync="addCatDialoge">
    <el-form :model="addCatDialogeForm" label-width="80px">
      <el-form-item label="分类名称">
        <el-input
          v-model="addCatDialogeForm.cat_name"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="父级名称">
        <!-- 级联选择器 -->
        <el-cascader
          :options="options"
          change-on-select
          v-model="addCatDialogeForm.cat_pid_arr"
          :props="defaultProps"
        ></el-cascader>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="addCatDialoge = false">取 消</el-button>
      <el-button type="primary" @click="confirmToAddCat">确 定</el-button>
    </div>
  </el-dialog>
</div>
